package com.xw.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.xw.jsr303Group.RegisterGroup;
import com.xw.jsr303Group.SaveGroup;
import com.xw.jsr303Group.UpdateGroup;
import com.xw.util.RoleConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @Description: 用户实体类
 * @Author: ASUS
 * @Date: 2024/12/19 9:17
 * @Version: 1.0
 */

@Data
public class User {

    @ExcelIgnore
    @ApiModelProperty(value = "主键ID")
    private Integer id;

    @ExcelProperty("用户名")
    @ApiModelProperty(value = "用户名")
    @NotBlank(message = "用户名不能为空",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private String userName;

    @ExcelIgnore
    @ApiModelProperty(value = "密码")
    @NotBlank(message = "密码不能为空",groups = {RegisterGroup.class})
    private String password;

    @ExcelIgnore
    @ApiModelProperty(value = "昵称")
    @NotBlank(message = "昵称不能为空",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private String nickName;

    @ColumnWidth(25)
    @ExcelProperty("邮箱")
    @ApiModelProperty(value = "邮箱")
    @NotBlank(message = "邮箱不能为空",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private String email;

    @ExcelProperty("年龄")
    @ApiModelProperty(value = "年龄")
    @Min(value = 12, message = "年龄不能小于12岁",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    @Max(value = 100, message = "年龄不能大于100岁",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private Integer age;

    @ColumnWidth(15)
    @ExcelProperty("联系电话")
    @ApiModelProperty(value = "联系电话")
   // @Pattern(regexp = "^\\d{11}$", message = "联系电话必须是11位数字", groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private String phone;

    @ExcelIgnore
    @ApiModelProperty(value = "用户头像")
    private String imageUrl;

    @ExcelProperty(value="用户角色",converter = RoleConverter.class)
    @ApiModelProperty(value = "用户角色")
//    @NotBlank(message = "用户角色不能为空",groups = {RegisterGroup.class, SaveGroup.class, UpdateGroup.class})
    private String role;

    @ExcelIgnore
    @ApiModelProperty(value = "确认密码")
    @NotBlank(message = "确认密码不能为空",groups = RegisterGroup.class)
    private String confirmPassword;

    @ExcelIgnore
    @ApiModelProperty(value = "审核 0 未审核  1 审核通过  2 审核不通过")
    private Integer applyStatus;

    @ExcelIgnore
    private List<Integer> ids;
}
